//
//  TableViewCell.m
//  Meng
//
//  Created by dllo on 15/9/30.
//  Copyright (c) 2015年 ljw. All rights reserved.
//

#import "TableViewCell.h"

@implementation TableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.imageview = [[UIImageView alloc] init];
        
        [self.contentView addSubview:self.imageview];
        
        self.view = [[UIView alloc] init];
        self.view.backgroundColor = [UIColor colorWithRed:102 / 255.0 green:102 / 255.0 blue:102 / 255.0 alpha:0.5];
        [self.contentView addSubview:self.view];
        
        self.title = [[UILabel alloc] init];
        self.title.textColor = [UIColor whiteColor];
        self.title.font = [UIFont boldSystemFontOfSize:18];
        [self.view addSubview:self.title];
        
        self.likeView = [[UIView alloc] init];
        self.likeView.backgroundColor = [UIColor colorWithRed:51 / 255.0 green:51 / 255.0 blue:51 / 255.0 alpha:0.5];
        self.likeView.layer.cornerRadius = 15;
        [self.imageview addSubview:self.likeView];
        
        self.Likeimage = [[UIImageView alloc] init];
        [self.Likeimage setImage:[UIImage imageNamed:@"like.png"]];
        [self.imageview addSubview:self.Likeimage];
        
        self.likeNumber = [[UILabel alloc] init];
        self.likeNumber.textColor = [UIColor whiteColor];
        [self.imageview addSubview:self.likeNumber];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    
    return self;
    
}


- (void)layoutSubviews
{


    [super layoutSubviews];
    self.imageview.frame = CGRectMake(0, 0, W, W / 1.6);
    self.view.frame = CGRectMake(0, W / 1.93, W, W / 9.4);
    self.title.frame = CGRectMake(W / 37.5, W / 75, W, W / 12.5);
    self.likeView.frame = CGRectMake(W / 1.3, W / 37.5, W / 4.7, W / 12.5);
    self.Likeimage.frame = CGRectMake(W / 1.3, W / 37.5, W / 12.5, W / 12.5);
    self.likeNumber.frame = CGRectMake(W / 1.19, W / 37.5, W / 7.5, W / 12.5);
    
}

- (void)setHomemodel:(HomeModel *)homemodel
{
    
    if (_homemodel != homemodel) {
        [_homemodel release];
        _homemodel = [homemodel retain];
    }
    
    [self.imageview sd_setImageWithURL:[NSURL URLWithString:homemodel.cover_image_url] placeholderImage:[UIImage imageNamed:@"zhanweitu"]];
    
    self.title.text = homemodel.title;
    self.likeNumber.text = [NSString stringWithFormat:@"%@", homemodel.likes_count];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
